package blink.guimodel;

import java.util.ArrayList;
import java.util.List;

import javax.swing.AbstractListModel;

import blink.model.Experiment;
import blink.model.Task;

public class xpListModel extends AbstractListModel {

	private Experiment experiment;
	
	@Override
	public Object getElementAt(int arg0) {
		return experiment.getNbTrys(arg0);
	}

	@Override
	public int getSize() {
		return experiment.getTasks().size();
	}
	
	public void setToList(int taskIndex, int nbTry) {
		experiment.setNbTrys(taskIndex, nbTry);
		int size=getSize();
		this.fireIntervalAdded(this, size, size);
	}
	
	public void removeFromList(int idx) {
		if (idx != -1) {
			this.fireIntervalRemoved(this, idx, idx);
		}
	}

	public void setModel(Experiment model) {
		this.experiment = model;
	}

	public void fireContentsChanged(int selectedIndex) {
		fireContentsChanged(this, selectedIndex, selectedIndex);
	}

}
